<?php

Yii::app()->clientScript->registerScriptFile('/ueditor/editor_config.js');
Yii::app()->clientScript->registerScriptFile('/ueditor/editor_all_min.js');
Yii::app()->clientScript->registerCssFile("/ueditor/themes/default/ueditor.css");
Yii::app()->clientScript->registerCss("x", '#ui-datepicker-div {z-index:999}');
Yii::app()->clientScript->registerCss("x2", '.ui-datepicker { width: 17em; padding: .2em .2em 0; z-index: 9999 !important; }');
?>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'product-form',
	'enableAjaxValidation'=>false,
    'htmlOptions' => array('enctype'=>'multipart/form-data')
)); ?>
	<p class="note">标记为<span class="required">*</span>的项目为必填项.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>512)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>

	<div class="row">
		<?php include_once dirname(__FILE__).'/cat.php';?>
		<?php echo $form->labelEx($model,'category_id'); ?>
		<?php echo $form->dropDownList($model,'category_id', $t); ?>
		<?php echo $form->error($model,'category_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'date'); ?>
		<?php
		$this->widget ( 'zii.widgets.jui.CJuiDatePicker', array (
				'attribute' => 'date',
				'language' => 'zh_cn',
				'name' => 'Product[date]',
				'options' => array (
						'showAnim' => 'fold',
						'showOn' => 'both',
						'minDate' => 'new Date()',
						'dateFormat' => 'yy-mm-dd' 
				),
				'htmlOptions' => array (
					'style' => 'height:18px',
					'readonly' => true,
					'class' => $model->getError('date') ? 'error' : ''
				),
				'value' => $model->date
		) ); 
		?>
		<?php echo $form->error($model,'date'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'image'); ?>
        <?php echo CHtml::activeFileField($model, 'image'); ?>
		<?php echo $form->error($model,'image'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'content'); ?>
		<?php echo $form->error($model,'content'); ?>
		<script type="text/plain" id="editor" style="width: 600px;"><?php echo $model->content;?></script>
		<script>
            window.UEDITOR_CONFIG.textarea = "Product[content]";
	        new UE.ui.Editor().render('editor');
	    </script>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? '新增' : '保存'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
